<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <%@include file="../../common/include_list_head.jsp" %>
    <script type="text/javascript" src="${basePath }/component/datepicker/WdatePicker.js"></script>
    <!----信息提示start--->
    <link rel="stylesheet" href="${basePath}/component/msgbox/msgbox.css" type="text/css">
    <script type="text/javascript" src="${basePath}/component/msgbox/msgbox.js"></script>
    <!----信息提示end--->
    <script type="text/javascript">
        var jsonDate = ${jsonDate};

        $(function(){
            //checkbox绑定事件
            var selectedGZ = document.getElementById("selectedGZ");
            $("input[name='selectNode']").bind("click",function(){
                var thisCheck = $(this);
                if(thisCheck.attr("checked")==true){        //如果被选中
                    selectedGZ.value = selectedGZ.value.replace(thisCheck.val() +"|","");
                    selectedGZ.value += thisCheck.val() +"|";
                    addSelectedLabel(thisCheck.val(),thisCheck.attr('bt'))
                }else{
                    //删除相关数据
                    selectedGZ.value = selectedGZ.value.replace($(this).val() +"|","");
                    deleteSelectedLabel(thisCheck.val());
                }
            });

            $(".hand").bind("click",function(){
               var srcflag = $(this).attr('src');
                //console.debug(srcflag);
                if(srcflag.indexOf("Off")>0){   //全不选
                    myselectAll(false);
                }else {     //全选
                    myselectAll(true);
                }
            });
            loadAndSelect();
        });

        function szgxSave(){
            var url = "${basePath}"+"/business/regulation-szgxSave.action";
            var selectedGZValue = document.getElementById("selectedGZ").value;
            var zywidValue = document.getElementById("zywid").value;
            $.post(url,
                    {
                        zywid:zywidValue,
                        selectedGZ: selectedGZValue,
                        time: (new Date()).valueOf()
                    },
                    function (data) {
                        if("ok"!=data){
                            alert(data);
                            return false;
                        }else{
                            //alert("保存成功！");
                            $.msgbox.show({
                                message: '保存成功！',
                                icon: 'ok',
                                timeOut: 1000
                            });
                            return true;
                        }
                    });
        }
        /**
        *根据数据选择当前页面上已经选择的项目
        */
       function loadAndSelect(){
            var selectedGZValue = document.getElementById("selectedGZ").value;
            var array = selectedGZValue.split("|");
            if(array!=null&&array.length>0){
                for(var i = 0;i<array.length;i++){
                    var checkboxid = array[i];
                    if(checkboxid!=""){
                        $("#"+checkboxid).attr("checked",true);     //选中
                        //$("#test").val($("#"+checkboxid).attr("bt"));
                        addSelectedLabel(checkboxid,jsonDate[''+checkboxid+'']);
                    }
                }
            }
       }
       /**
        *全选或者反选
        * @param flag
        */
       function myselectAll(flag){
           var selectedGZ = document.getElementById("selectedGZ");
           $("input[name='selectNode']").each(function(i, o){
               var thisCheck = $(this);
               if(flag){        //全选
                   selectedGZ.value = selectedGZ.value.replace(thisCheck.val() +"|","");
                   selectedGZ.value += thisCheck.val() +"|";
                   //thisCheck.attr("checked",true);
                   addSelectedLabel(thisCheck.val(),thisCheck.attr('bt'));
               }else{           //全不选
                   selectedGZ.value = selectedGZ.value.replace($(this).val() +"|","");
                   deleteSelectedLabel(thisCheck.val());
               }

           });
       }

        function addSelectedLabel(wid,title){
            var panel = $("#selected_class");
            var htmlsource = "<li id='li_"+wid+"'><a href=\"javascript:void(0)\" title=\""+title+"\"><h5 onclick='window.open(\"${basePath}/s/rulesdetail/"+wid+"\")'>\n" +title+
                    "</h5><span onclick=\"deleteSelectedLabel('"+wid+"')\" class=\"icon-todo-close\"></span></a></li>";
            panel.append(htmlsource);
        }

        function deleteSelectedLabel(wid){
            var selectedGZ = document.getElementById("selectedGZ");
            $("#"+"li_"+wid).remove();
            selectedGZ.value = selectedGZ.value.replace(wid +"|","");
            $("#"+ wid).attr("checked",false);
        }
    </script>
    <style type="text/css">

        .cate-property{
            background: none repeat scroll 0 0 white;
            border-top: 1px solid #CCCCCC;
        }
        .cate-property .section {
            border-bottom: 1px dotted #DDDDDD;
            margin: 0 10px;
        }
        .section:before, .section:after {
            content: "";
            display: table;
        }
        .section:after {
            clear: both;
        }
        .section .hd {
            display: inline;
            float: left;
        }
        .navigation .section .hd {
            height: 30px;
            line-height: 30px;
            padding-left: 10px;
            text-align: right;
            width: 70px;
        }
        .cate-property .section .hd {
            overflow: hidden;
            padding-left: 0;
            text-overflow: ellipsis;
            white-space: nowrap;
            width: 90px;
            word-wrap: break-word;
        }
        .section .bd {
            margin-left: 70px;
        }
        .clearfix:after {
            clear: both;
            content: " ";
            display: block;
            height: 0;
        }
        .searchnav {
            list-style: none outside none;
            padding-left: 0px;
        }
        .section .searchnav {
            height: 30px;
            line-height: 30px;
            overflow: hidden;
        }
        .section-open .searchnav {
            height: auto;
        }
        .searchnav li {
            float: left;
        }
        .section .searchnav li {
            padding: 0 16px;
        }
        .searchnav li a {
            display: block;
            padding: 0 8px;
        }
        .section .searchnav a {
            padding: 0;
            white-space: nowrap;
        }
        .navigation {
            border-left: 1px solid #CCCCCC;
            border-right: 1px solid #CCCCCC;
            border-top: 2px solid #FF5500;
            margin-top: 10px;
        }
        .navigation .cate-selected {
            background: none repeat scroll 0 0 #F2F2F2;
            height: auto;
            line-height: 18px;
            padding: 8px 10px 0;
        }
        .navigation .cate-selected .hd {
            height: 25px;
            line-height: 18px;
            white-space: nowrap;
            width: auto;
        }
        .navigation .cate-selected .nav-pills {
            background: none repeat scroll 0 0 transparent;
            border: 0 none;
            height: 28px;
            overflow: visible;
        }
        .nav-pills:before, .nav-pills:after, .nav-stack:before, .nav-stack:after, .nav-list:before, .nav-list:after {
            content: "";
            display: table;
        }
        .nav-pills:before, .nav-pills:after, .nav-stack:before, .nav-stack:after, .nav-list:before, .nav-list:after {
            content: "";
            display: table;
        }
        .nav-pills:after, .nav-stack:after, .nav-list:after {
            clear: both;
        }
        .searchnav li {
            float: left;
        }
        .navigation .section .searchnav li {
            padding: 0 16px;
        }
        .navigation .cate-selected .searchnav li {
            margin-bottom: 7px;
            margin-right: 5px;
            padding: 0;
        }
        .navigation .cate-selected .searchnav a {
            background: none repeat scroll 0 0 white;
            border: 1px solid #FF8040;
            color: #FF8040;
            display: block;
            height: 17px;
            line-height: 17px;
            padding: 0 15px 0 3px;
            position: relative;
            white-space: nowrap;
        }
        .navigation .cate-selected .searchnav h5 {
            color: gray;
            display: inline;
            font-size: 12px;
            font-weight: normal;
        }
        .navigation .cate-selected .searchnav a .icon-todo-close {
            height: 14px;
            position: absolute;
            right: 1px;
            top: 2px;
            width: 14px;
        }
        .icon-todo-close {
            background: url("${basePath}/clientui/common/img/listBG.gif") no-repeat scroll 0 0 transparent;
            float: left;
            font-size: 0;
            background-position: 0px -543px;
        }
    </style>
</head>
<body>
<div id="scrollContent22">

    <s:if test="actionErrors.size()>0 || actionMessages.size()>0 || fieldErrors.size()>0">
        <div id="SystemErrorMessage">
            <s:actionerror/>
            <s:actionmessage/>
            <s:fielderror/>
        </div>
    </s:if>
    <s:hidden name="zywid" id="zywid"/>
    <s:form theme="simple" name="ysform">
        <s:hidden name="pager.formname" value="ysform"/>
        <s:hidden name="pager.currentPageno" id="yspager_currentPageno"/>
        <div style="margin: 10px">
            <s:hidden name="selectedGZ" id="selectedGZ" cssStyle="width: 500px;"/>
        </div>

    </s:form>


    <div class="navigation wrapper-box" id="brix_brick_25" style="padding-top: 0px;">
        <div class="section cate-selected">
            <div class="hd">您已选择：</div>
            <div class="bd">
                <ul class="searchnav nav-pills" id="selected_class">
                </ul>

            </div>
            <div style="float: right;margin-bottom: 5px;"><button onclick="szgxSave()"><span class="icon_save">保存</span></button></div>
        </div>
    </div>


    <div>
        <table class="tableStyle" style="width:100%;">
            <tr>
                <th width="3%"></th>
                <th nowrap="nowrap" width="20%">标题</th>
                <th nowrap="nowrap" width="20%">内容摘要</th>
                <th nowrap="nowrap" width="5%">资源数</th>
                <th nowrap="nowrap" width="10%">创建人</th>
                <th nowrap="nowrap" width="10%">创建时间</th>
                <th nowrap="nowrap" width="10%">附件</th>

            </tr>
            <s:iterator value="resultData">
                <tr>
                    <td align="center"><s:checkbox id="%{wid}" name="selectNode" fieldValue="%{wid}" bt="%{bt}"/></td>
                    <td nowrap="nowrap">
                        <span class="text_slice" style="width:200px;" title='<s:property value="bt"/>'><a class="bluea" target="_blank" href="${basePath}/s/rulesdetail/<s:property value="wid"/>"><s:property value="bt"/></a></span>
                    </td>
                    <td nowrap="nowrap"><span class="text_slice" style="width:200px;" title='<s:property value="nrzy"/>'><s:property value="nrzy"/></span></td>
                    <td nowrap="nowrap"><a class="bluea" title="设置关联的资源" href="javascript:szzy('<s:property value="wid"/>')"><s:property value="zys"/></a></td>
                    <td nowrap="nowrap"><s:property value="cjr"/></td>
                    <td nowrap="nowrap"><s:date format="yyyy-MM-dd HH:mm" name="jlcssj" /></td>

                    <td nowrap="nowrap">
                        <s:if test="fjdz !=null">
                            <a target="_blank" class="bluea" title="<s:property value="fjmc"/>" href='${basePath}/<s:property value="fjdz"/>'>下载</a>
                        </s:if>
                    </td>
                </tr>
            </s:iterator>
        </table>
    </div>
    <div style="height: 45px;">
        <div id="pagelist" style="display: none">
            <s:property value="pager.postToolBar" escape="false"/>
        </div>

        <div class="clear"></div>
    </div>
</div>
</body>
</html>
